package C50;

/**
 * ClassName: C02
 * Package: C50
 * Description:
 *
 * @Author BCXJ
 * @Create 2025/2/27 18:13
 * @Version 1.0
 * @Since 1.0
 */
public class C02 {
    public static int findDuplicate(int[] nums) {
        int slow = nums[0];
        int fast = nums[nums[0]];
        while (fast != slow) {
            slow = nums[slow];
            fast = nums[nums[fast]];
        }
        fast = 0;
        while (fast != slow) {
            fast = nums[fast];
            slow = nums[slow];
        }
        return slow;
    }
}
